package cz.semjobKB.webapp;

import com.vaadin.annotations.PreserveOnRefresh;
import com.vaadin.annotations.Theme;
import com.vaadin.annotations.Title;
import com.vaadin.annotations.VaadinServletConfiguration;
import com.vaadin.server.VaadinRequest;
import com.vaadin.server.VaadinServlet;
import com.vaadin.ui.UI;
import cz.semjobKB.gui.EntryWindow;
import org.springframework.beans.factory.annotation.Configurable;
import org.springframework.stereotype.Component;
import org.springframework.web.context.support.WebApplicationContextUtils;

import javax.servlet.annotation.WebServlet;

/**
 * Main entry class
 */
@Configurable
@Theme("chameleon")
@PreserveOnRefresh
@Title("SemjobKB")
@Component
@SuppressWarnings("serial")
public class SemjobKB extends UI
{
	
	EntryWindow entryWindow;
	
	@WebServlet(value = "/*", asyncSupported = true)
	@VaadinServletConfiguration(productionMode = false, ui = SemjobKB.class)  
    public static class Servlet extends VaadinServlet {
    }

    /*
        Entry
     */
    protected void init(VaadinRequest request) {
    	
    	entryWindow = WebApplicationContextUtils.getRequiredWebApplicationContext(
    			VaadinServlet.getCurrent().getServletContext()).getBean(EntryWindow.class);
    	
        setContent(entryWindow);        
    }

}
